/** * The array buffer into which the components of the vector are * stored. The capacity of the vector is the length of this array buffer, * and is at least large enough to contain all the vector's elements. * * <p>Any array elements following the last element in the Vector are null. * * @serial */ protected Object[] elementData;
/** * The number of valid components in this {@code Vector} object. * Components {@code elementData[0]} through * {@code elementData[elementCount-1]} are the actual items. * * @serial */ protectedint elementCount;
/** * The amount by which the capacity of the vector is automatically * incremented when its size becomes greater than its capacity. If * the capacity increment is less than or equal to zero, the capacity * of the vector is doubled each time it needs to grow. * * @serial */ protectedint capacityIncrement;
/** use serialVersionUID from JDK 1.0.2 for interoperability */ privatestaticfinallongserialVersionUID= -2767605614048989439L;
publicsynchronizedbooleanremoveElement(Object obj) { modCount++; inti= indexOf(obj); if (i >= 0) { removeElementAt(i); returntrue; } returnfalse; }
publicsynchronizedvoidremoveElementAt(int index) { modCount++; if (index >= elementCount) { thrownewArrayIndexOutOfBoundsException(index + " >= " + elementCount); }elseif (index < 0) { thrownewArrayIndexOutOfBoundsException(index); } intj= elementCount - index - 1; if (j > 0) { System.arraycopy(elementData, index + 1, elementData, index, j); } elementCount--; elementData[elementCount] = null; /* to let gc do its work */ }
publicsynchronized E remove(int index) { modCount++; if (index >= elementCount) thrownewArrayIndexOutOfBoundsException(index); EoldValue= elementData(index);
intnumMoved= elementCount - index - 1; if (numMoved > 0) System.arraycopy(elementData, index+1, elementData, index, numMoved); elementData[--elementCount] = null; // Let gc do its work
/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ funcreverseKGroup(head *ListNode, k int) *ListNode { var tmp,res *ListNode = head,head if k <= 1 { return head } varcap []*ListNode = make([]*ListNode, k+2) LOOP: for tmp != nil { for i:=1; i <= k;i++{ cap[i] = tmp; if tmp.Next != nil || i == k { tmp = tmp.Next }else{ cap[0].Next = cap[1] break LOOP } } ifcap[1] == head { res = cap[k] }
for i:= k; i>=1;i--{ if i != 1{ cap[i].Next = cap[i-1] }else{ cap[1].Next = nil ifcap[0] != nil{ cap[0].Next = cap[k] } cap[0] = cap[1] } } } return res }
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { synchronized (getClassLoadingLock(name)) { // First, check if the class has already been loaded Class<?> c = findLoadedClass(name); if (c == null) { longt0= System.nanoTime(); try { if (parent != null) { c = parent.loadClass(name, false); } else { c = findBootstrapClassOrNull(name); } } catch (ClassNotFoundException e) { // ClassNotFoundException thrown if class not found // from the non-null parent class loader }
if (c == null) { // If still not found, then invoke findClass in order // to find the class. longt1= System.nanoTime(); c = findClass(name);
// this is the defining class loader; record the stats PerfCounter.getParentDelegationTime().addTime(t1 - t0); PerfCounter.getFindClassTime().addElapsedTimeFrom(t1); PerfCounter.getFindClasses().increment(); } } if (resolve) { resolveClass(c); } return c; } }